<template>
	<view class="container">
		<view class="realname" style="width: 94%;margin-left: 3%;">
			<bjx-form-item class="realname-user" label-type="inline" prop="introduce">
				<textarea class="realname-content" placeholder="请描述你的问题" v-model="description" />
			</bjx-form-item>
		</view>
		<view class="submit-box">
			<view class="submit" style="letter-spacing: 4upx;" @tap="clickConfirm">
				提交
			</view>
		</view>
	</view>
</template>

<script>
	import {
		mapState,
		mapMutations
	} from 'vuex';
	export default {
		data() {
			return {
				description: ''
			}
		},
		computed: {
			...mapState(['hasLogin']),
		},
		onLoad() {
			
		},
		methods: {
			// 触发提交表单
			async clickConfirm() {
				//判断是否登录
				let result = this.$api.isLogin();
				if (result === false) {
					return false;
				}
		
				if (!this.description) {
					this.$api.msg('请输入意见内容！');
					return false;
				}
				let token = uni.getStorageSync('token')
				let dataObj = {
					token: token,
					description: this.description
				};
				this.submit(dataObj);
			},
		
			//登录提交
			async submit(dataObj) {
				let res = await this.$myRequest({
					url: '/addOpinion',
					data: dataObj,
					methods: 'post'
				})
		
				if (res.data.status == 1) {
					this.$api.msg('提交成功', 'success', 1000);
					setTimeout(() => {
						uni.switchTab({
							url: '/pages/user/user'
						})
					}, 1000)
				} 
			},
		},
	}
</script>

<style lang="scss">
	page {
		background: #FFFFFF;
	}

	.container {
		// #ifdef APP-PLUS
		padding-top: 156rpx;
		// #endif

		// #ifdef MP-WEIXIN
		padding-top: 156rpx;
		// #endif

		// #ifdef H5
		padding-top: 116rpx;
		// #endif
	}

	.realname {
		background: #f7f7f7;
		border-radius: 25upx;
		margin-top: -80rpx;

		.realname-content {
			font-size: 28upx;
			color: #333;
			padding: 22rpx;
			height: 200rpx;
		}
	}

	.submit-box {
		width: 94%;
		margin-left: 3%;
		margin-top: 80upx;

		.submit {
			background-color: #29ad97;
			height: 88rpx;
			border-radius: 44rpx;
			color: #fff;
			display: flex;
			align-items: center;
			justify-content: center;
			font-size: 30upx;
		}
	}

	.realname {
		color: #808080 !important;
	}
</style>
